package me.thinkjet.sso.server.authentication;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 
 * @ClassName Authentication
 * @author johnny_zyc
 * @Modified 2013-3-2 下午2:45:42
 * 
 */
public class Authentication implements Serializable {

	private static final long serialVersionUID = 5919171958487554698L;

	private final String id;
	private Map<String, Object> attributes;
	private final Date authenticatedDate = new Date();

	public Authentication(final String id) {
		this(id, new HashMap<String, Object>());
	}

	public Authentication(final String id, Map<String, Object> attributes) {
		this.id = id;
		this.attributes = attributes;
	}

	public Date getAuthenticatedDate() {
		return this.authenticatedDate;
	}

	public final Map<String, Object> getAttributes() {
		return this.attributes;
	}

	public final String getId() {
		return this.id;
	}

	public final boolean equals(final Object o) {
		if (o == null || !this.getClass().isAssignableFrom(o.getClass())) {
			return false;
		}

		Authentication a = (Authentication) o;

		return this.id.equals(a.getId())
				&& this.getAuthenticatedDate().equals(a.getAuthenticatedDate())
				&& this.attributes.equals(a.getAttributes());
	}

}
